home *** CD-ROM | disk | FTP | other *** search
Oberon Text | 1995-08-22 | 2.5 KB | 77 lines | [TEXT/.Ob4] |
- Syntax10.Scn.Fnt
- StampElems
- Alloc
- 24 Nov 94
- Syntax10b.Scn.Fnt
- MODULE DirElems; (** HM
- IMPORT Viewers, Texts, TextFrames, Oberon, PopupElems, Directories;
- Elem* = POINTER TO ElemDesc;
- ElemDesc* = RECORD (PopupElems.ElemDesc)
- END;
- w: Texts.Writer;
- PROCEDURE ReadName (t: Texts.Text; pos: LONGINT; VAR name: ARRAY OF CHAR);
- VAR r: Texts.Reader; ch, stopch: CHAR; i: INTEGER;
- BEGIN
- Texts.OpenReader(r, t, pos); Texts.Read(r, ch); i := 0;
- IF ch = '"' THEN Texts.Read(r, ch);
- WHILE ~r.eot & (ch # '"') DO name[i] := ch; INC(i); Texts.Read(r, ch) END
- ELSE
- WHILE ~r.eot & (ch > " ") DO name[i] := ch; INC(i); Texts.Read(r, ch) END
- END;
- name[i] := 0X
- END ReadName;
- PROCEDURE SetDirName (e: Elem; defName: ARRAY OF CHAR);
- VAR vRef, i, j: INTEGER; dirID: LONGINT; name: ARRAY 256 OF CHAR;
- BEGIN
- IF defName = "" THEN
- Directories.GetCurDir(name, vRef, dirID);
- Directories.GetFullPath(vRef, dirID, name)
- ELSE COPY(defName, name)
- END;
- i := 0; WHILE name[i] # 0X DO INC(i) END;
- IF i < 32 THEN COPY(name, e.name)
- ELSE e.name[31] := 0X; j := 31;
- REPEAT DEC(i); DEC(j); e.name[j] := name[i] UNTIL j = 1;
- e.name[0] := "*"
- END SetDirName;
- PROCEDURE Exec (e: Elem; pos: LONGINT);
- VAR m: TextFrames.UpdateMsg; res: INTEGER; name: ARRAY 256 OF CHAR;
- BEGIN
- ReadName(e.menu, pos, name);
- Directories.ChangeDir(name, res);
- IF res = 0 THEN
- IF (name = "::") OR (name = "$") THEN name := "" END;
- SetDirName(e, name);
- m.id := TextFrames.replace; m.text := Texts.ElemBase(e); m.beg := Texts.ElemPos(e); m.end := m.beg + 1;
- Viewers.Broadcast(m)
- ELSE Texts.WriteString(w, " -- failed"); Texts.WriteLn(w); Texts.Append(Oberon.Log, w.buf)
- END Exec;
- PROCEDURE Handle* (e: Texts.Elem; VAR m: Texts.ElemMsg);
- VAR e1: Elem;
- BEGIN
- WITH e: Elem DO
- WITH
- m: Texts.CopyMsg DO
- NEW(e1); m.e := e1; PopupElems.Handle(e, m)
- | m: Texts.IdentifyMsg DO
- m.mod := "DirElems"; m.proc := "Alloc"
- | m: PopupElems.ExecMsg DO Exec(e, m.pos)
- ELSE PopupElems.Handle(e, m)
- END
- END Handle;
- PROCEDURE Alloc*;
- VAR e: Elem;
- BEGIN
- NEW(e); e.handle := Handle; Texts.new := e
- END Alloc;
- PROCEDURE Insert*;
- VAR e: Elem; insert: TextFrames.InsertElemMsg;
- BEGIN
- NEW(e); e.handle := Handle; e.small := FALSE; SetDirName(e, "");
- e.menu := TextFrames.Text(""); PopupElems.MeasureMenu(e);
- insert.e := e; Viewers.Broadcast(insert)
- END Insert;
- BEGIN
- Texts.OpenWriter(w)
- END DirElems.
-